package com.xqh.javabasic.input_output_device;
import java.io.FileOutputStream;
public class SaveIntToFile_MoveBit_BitAnd{
		
	public static void saveIntToFile_MoveBit_BitAnd() throws Exception{
		FileOutputStream  fos = new FileOutputStream("d:/data");
			int x = 123456;
		byte b3,b2,b1,b0;
		
			b0 = (byte)x ;
			b1 = (byte)((x & 0b00000000000000001111111100000000) >> 1 * 8);
			b2 = (byte)((x & 0b00000000111111110000000000000000) >> 2 * 8);
			b3 = (byte)((x & 0b11111111000000000000000000000000) >> 3 * 8);
		
		fos.write(b3);
		fos.write(b2);
		fos.write(b1);
		fos.write(b0);
	fos.close();
	}
public static void main(String [] args) throws Exception{

		saveIntToFile_MoveBit_BitAnd();
		
	}
}		

